package com.sunxueqi.framework.security.service;

import java.util.HashSet;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sunxueqi.project.system.service.MenuService;
import com.sunxueqi.project.system.service.RoleService;
import com.sunxueqi.project.system.vo.User;

@Component
public class PermissionService {

	@Autowired
	private RoleService roleService;
	
	@Autowired
	private MenuService menuService;
	
	/**
	 * 获取对应用户的菜单权限
	 * @param user
	 */
	public Set<String> getMenuPermission(User user){
		Set<String> roles = new HashSet<String>();
		if(user.isAdmin()) {
			roles.add("*:*:*");
		} else {
			roles.addAll(menuService.selectMenusByUserId(user.getId()));
		}
		return roles;
	}

	/**
	 * @param user
	 * @return
	 */
	public Set<String> getRolePermission(User user){
		
		return null;
	}
}
